//
//  MACID.m
//  SpendMoney
//
//  Created by  lixinxin on 17/2/22.
//  Copyright © 2017年  lixinxin. All rights reserved.
//

#import "MACID.h"
//#import <ifaddrs.h>
//#import <arpa/inet.h>
//#import <net/if.h>
//
//#define IOS_CELLULAR    @"pdp_ip0"
//#define IOS_WIFI        @"en0"
//#define IOS_VPN         @"utun0"
//#define IP_ADDR_IPv4    @"ipv4"
//#define IP_ADDR_IPv6    @"ipv6"

#import <SystemConfiguration/CaptiveNetwork.h>


@implementation MACID



+ (NSDictionary *)SSIDInfo

{
    
    NSArray *ifs = (__bridge_transfer NSArray *)CNCopySupportedInterfaces();
    
    NSDictionary *info = nil;
    
    for (NSString *ifnam in ifs) {
        
        info = (__bridge_transfer NSDictionary *)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
        
        if (info && [info count]) {
            
            break;
            
        }
        
    }
    
    return info;
    
}
// 可以直接根据

//+ (BOOL)isConnectedWifi
//
//{
//    
//    NSString *ssid = [[self SSIDInfo] objectForKey:@"SSID"];
//    
//    return ssid.length > 0;
//    
//}



//+ (NSString *) macaddress
//{
//    
//    NSString *ipAddress = nil;
//    
//    struct ifaddrs *ifa_list = NULL;
//    struct ifaddrs *tmp = NULL;
//    int result;
//    
//    result = getifaddrs(&ifa_list);
//    
//    if(result == 0)
//    {
//        tmp = ifa_list;
//        ipAddress = @"";
//        
//        while(tmp){
//            if(tmp->ifa_addr->sa_family == AF_INET){
//                if([[NSString stringWithUTF8String:tmp->ifa_name] isEqualToString:@"en0"])
//                {
//                    ipAddress = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)tmp->ifa_addr)->sin_addr)];
//                    break;
//                }
//            }
//            tmp = tmp->ifa_next;
//        }
//    }
//    
//    freeifaddrs(ifa_list);
//    return ipAddress;
//
//}




@end
